package com.xcc.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: FanoutRabbitConfig
 * @Author: xiechuang
 * @Date: 2022/12/5
 */

@Configuration
public class FanoutRabbitConfig {

    @Bean
    public Queue queueKey1() {
        return new Queue("fanout.key1");
    }

    @Bean
    public Queue queueKey2() {
        return new Queue("fanout.key2");
    }

    @Bean
    public Queue queueKey3() {
        return new Queue("fanout.key3");
    }

    @Bean
    FanoutExchange fanoutExchange() {
        return new FanoutExchange("fanoutExchange");
    }

    @Bean
    Binding bindingExchangeA() {
        return BindingBuilder.bind(queueKey1()).to(fanoutExchange());
    }

    @Bean
    Binding bindingExchangeB() {
        return BindingBuilder.bind(queueKey2()).to(fanoutExchange());
    }

    @Bean
    Binding bindingExchangeC() {
        return BindingBuilder.bind(queueKey3()).to(fanoutExchange());
    }

}
